package lab01;
import java.util.Scanner;

/**
 * Created by 其 on 2016/4/8.
 */

public class CalculatorDemo {
    public static void main(String[] args) {
        Scanner scanner1 = new Scanner(System.in);
        Scanner scanner2 = new Scanner(System.in);
        Scanner scanner3 = new Scanner(System.in);
        Calculator calculator = new Calculator();
        System.out.print("First Number:   ");
        double a = scanner1.nextDouble();
        System.out.print("Calculate Type:   ");
        String type = scanner2.next();
        System.out.print("Second Number:   ");
        double b = scanner3.nextDouble();
        switch (type){
            case "+":
                calculator.add(a, b);
                System.out.println(calculator.getResult());
                break;
            case "-":
                calculator.subtract(a, b);
                System.out.println(calculator.getResult());
                break;
            case "*":
                calculator.multiply(a, b);
                System.out.println(calculator.getResult());
                break;
            case "/":
                calculator.divide(a, b);
                if(calculator.isFlag()) {
                    System.out.println(calculator.getResult());
                    break;
                }
            default:
                System.out.println("Error!");
        }
    }
}
